package co.fitstart.admin.web.controller.course;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import co.fitstart.admin.service.BasicInformationService;
import co.fitstart.admin.service.CourseRoundService;
import co.fitstart.admin.web.interceptor.MenuSetting;
import co.fitstart.entity.course.round.CourseRound;
import co.fitstart.entity.course.round.Goal;
import co.fitstart.entity.courseware.assessment.BasicData;
import co.fitstart.entity.courseware.assessment.PostureJoint;
import co.fitstart.entity.courseware.assessment.StudentHabit;
import co.fitstart.entity.user.basic.BodyDataTarget;

/**
 * 基础信息
 * @author haiyan_xiao
 *
 */
@Controller
@RequestMapping("/individual-rounds/{courseRoundId}/basic-information")
@MenuSetting("menu-course")
public class BasicInformationController {
    
    @Autowired
    private CourseRoundService courseRoundService;
    
    @Autowired
    private BasicInformationService basicInformationService;
    
    /**
     * 
     * @param courseRoundId
     * @return
     */
    @RequestMapping(value = "", method = RequestMethod.GET)
    @MenuSetting("submenu-individual-course-arrange")
    public ModelAndView basicInformationview(@PathVariable("courseRoundId") Long courseRoundId) {
        
        ModelAndView modelAndView = new ModelAndView("course/individual/individual-round-basic-information-view");
        
        CourseRound courseRound = courseRoundService.loadCourseRound(courseRoundId);
        modelAndView.addObject("courseRound", courseRound);
        
        Goal goal = basicInformationService.loadGoal(courseRound);
        modelAndView.addObject("goal", goal);
        
        List<BodyDataTarget> targets = basicInformationService.listBodyDataTarget(courseRound);
        modelAndView.addObject("targets", targets);
        
        BasicData basicData = basicInformationService.loadBasicData(courseRound);
        modelAndView.addObject("basicData", basicData);
        
        StudentHabit habit = basicInformationService.loadStudentHabit(courseRound);
        modelAndView.addObject("habit", habit);
        
        PostureJoint postureJoint = basicInformationService.loadPostureJoint(courseRound);
        modelAndView.addObject("postureJoint", postureJoint);
        
        return modelAndView;
    }
}
